<?php namespace Admin\Controller;
use Hdphp\Controller\Controller;
//链接管理控制器 
class LinkController extends CommonController{
	private $model;
	public function __init(){
		parent::__init();
		$this->model=new \Common\Model\Link;
	}
	//首页展示方法
	public function index(){
		$data=$this->model->get();
		View::with('data',$data);
		View::make();
	}
	//添加模板
	public function add(){
		if(IS_POST){
			if($this->model->store()) View::success('添加成功',U('index'));
			View::error($this->model->getError());
		}
		View::make();
	}
	public function edit(){
		if(IS_POST){
			if(!$this->model->edit()) View::error($this->model->getError());
			View::success('编辑成功',U('index'));
		}
		$data=$this->model->where("lid=".Q('get.lid',0,'intval'))->find();
		View::with('data',$data);
		View::make();
	}
	//删除
	public function del(){
		$this->model->where("lid=".Q('get.lid',0,'intval'))->delete();
		View::success('删除成功',U('index'));
	}
}






 ?>